home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-08-18 | 3.9 KB | 138 lines | [TEXT/R*ch] |
- (* Exec_phr.sml *)
- open List BasicIO Nonstdio Miscsys Fnlib Mixture Globals Units Types Asynt;
- open Infixst Ovlres Infixres Elab Pr_zam Tr_env Front Back Compiler;
- open Symtable Rtvals Load_phr;
-
- (* Executing a top-level declaration. *)
-
- fun report_results iBas cBas static_VE static_TE =
- let val firstLine = ref true in
- app
- (fn x =>
- (msgIBlock 0;
- if !firstLine then (firstLine := false; msgPrompt "")
- else msgContPrompt "";
- reportFixityResult x;
- msgEOL();
- msgEBlock()))
- (cleanEnv iBas);
- app
- (fn (id, tn) =>
- (msgIBlock 0;
- if !firstLine then (firstLine := false; msgPrompt "")
- else msgContPrompt "";
- reportTypeResult tn;
- msgEOL();
- msgEBlock()))
- (cleanEnv static_TE);
- app
- (fn (id,sch) =>
- let val status = lookup_new_cBas cBas id
- val {qualid, info} = status
- in
- msgIBlock 0;
- msgCBlock 0;
- (if !firstLine then (firstLine := false; msgPrompt)
- else msgContPrompt)
- (case info of
- VARname _ => "val "
- | PRIMname _ => "val "
- | CONname _ => "con "
- | EXNname _ => "exn "
- | REFname => "con ");
- msgString id;
- msgString " ="; msgBreak(1, 4);
- (case info of
- VARname _ =>
- let val slot = get_slot_for_variable (lookupRenEnv qualid)
- val v = getGlobalVal slot
- in printVal sch v end
- | PRIMname pi =>
- if #primArity pi = 0 then
- msgString "-"
- else
- msgString "fn"
- | CONname ci =>
- if #conArity(!ci) = 0 then
- printVQ qualid
- else
- msgString "fn"
- | EXNname ei =>
- if #exconArity(!ei) = 0 then
- printVQ qualid
- else
- msgString "fn"
- | REFname =>
- msgString "fn");
- msgBreak(1, 4); msgString ": "; printScheme sch;
- msgEBlock();
- msgEOL();
- msgEBlock()
- end)
- (cleanEnv static_VE)
- end
- ;
-
- (* This is written in tail-recursive form to ensure *)
- (* that the intermediate results will be discarded. *)
-
- fun updateCurrentState ((iBas, cBas, VE, TE), RE) =
- (
- catch_interrupt false;
- updateCurrentInfixBasis iBas;
- updateCurrentConBasis cBas;
- updateCurrentStaticTE TE;
- updateCurrentStaticVE VE;
- updateCurrentRenEnv RE;
- catch_interrupt true;
- report_results iBas cBas VE TE;
- msgFlush()
- );
-
- fun execLamPhrase state (RE, tlams) =
- (
- app
- (fn (is_pure, lam) =>
- ( (* msgIBlock 0; Pr_lam.printLam lam; msgEOL(); msgEBlock(); *)
- ignore (loadZamPhrase
- let val zam = compileLambda is_pure lam in
- (* printZamPhrase zam; msgFlush(); *)
- zam
- end)
- ))
- tlams;
- updateCurrentState (state, RE)
- );
-
- fun execResolvedDecPhrase (iBas, cBas, dec) =
- let val (VE, TE) = elabToplevelDec dec in
- resolveOvlDec dec;
- execLamPhrase (iBas, cBas, VE, TE) (translateToplevelDec dec)
- end
- ;
-
- fun execToplevelPhrase dec =
- execResolvedDecPhrase (resolveToplevelDec dec)
- ;
-
- (* Executing a top-level signature specification *)
-
- (* This is written in tail-recursive form to ensure *)
- (* that the intermediate results will be discarded. *)
-
- fun updateCurrentSigState (iBas, cBas, VE, TE) =
- (
- updateCurrentInfixBasis iBas;
- updateCurrentConBasis cBas;
- updateCurrentStaticTE TE;
- updateCurrentStaticVE VE;
- report_comp_results iBas cBas VE TE;
- msgFlush()
- );
-
- fun execToplevelSpecPhrase spec =
- let val (iBas, cBas) = resolveToplevelSpec spec
- val (VE, TE) = elabToplevelSpec spec
- in updateCurrentSigState (iBas, cBas, VE, TE) end
- ;
-